home *** CD-ROM | disk | FTP | other *** search
- Path: uuneo.neosoft.com!usenet
- From: Wmatthew@lan-aces.com (W. Matthews)
- Newsgroups: comp.lang.c++
- Subject: Re: Q: how to create an Object without creating the whole object
- Date: 14 Mar 1996 15:43:20 GMT
- Organization: LAN-ACES, Inc.
- Message-ID: <4i9eqo$dtu@uuneo.neosoft.com>
- References: <31454EC9.167E@imacsg2.epfl.ch>
- NNTP-Posting-Host: 198.65.178.8
- X-Newsreader: WinVN 0.92.5
-
- In article <31454EC9.167E@imacsg2.epfl.ch>, Niels Hilbrink <niels@imacsg2.epfl.ch> says:
- >
- >Hi,
- >
- >Oke the problem is this (maybe it's in a FAQ but couldn't find the faq
- >so ...):
- >
- >Say you've got a class A which is composed of say 10 other class
- >(inheritance multiple and single whatever). But if I create an object
- >with new this class 'explodes' (all the member functions are created of
- >all the parentclasses) so you want the initialize only those parent
- >class you need say only class B.
- >
- >How do you do that ?
- >
- >something like:
- >
- > Aobj = (A*) new A::B()
- >
- >But this doen't work, can anybody tell me what will ?
- >
- >oh yeah this works of course :
- > Bobj = new B;
- >
- > Aobj = (A*) Bobj;
- >
- >but I don't want that, I don't want first to have to create a B object
- >and "attach" it to the A object
- >
- >Gr.
- >Niels
- >
- >--
- >
- > The most overlooked advantage to owning a computer is
- > that if they foul up there's no law against wacking
- > them around a little.
- >
- >------------------------------------------------------------
- >Koen D'Hondt Niels Hilbrink
- >koen@dutlhs1.lr.tudelft.nl niels@dutlcc3.lr.tudelft.nl
- >
- >**** Ripley Software Development ****
- >(finger niels@dutlcc3.lr.tudelft.nl for more information.)
- >------------------------------------------------------------
- Have you tried using a generic base class? Then, in class 'A'
- call the base with the appropriate class conversions to get 'B'.
- <Don't mind me, I may turn out to be rambling on this one.>
- ______________________________________________
- |Wyatt Matthews: Tech Support Department |
- |WMATTHEW@LAN-ACES.COM -Internet- |
- |WMATTHEW.MHS@LAN-ACES -MHS- |
- |LAN-ACES Tech Support (713)890-9786 |
- |LAN-ACES BBS (713)890-9790 |
- |LAN-ACES Fax (713)890-9731 |
- |LAN-ACES Sales (713)890-9787 |
- ______________________________________________
-